/*
  ODALedPanel.h - 
*/
#ifndef ODALedPanel_h
#define ODALedPanel_h

#include "WProgram.h"

const uint8_t LED_OFF    = 0;
const uint8_t LED_ON     = 1;
const uint8_t BLINK_SLOW = 2;
const uint8_t BLINK_NORM = 3;
const uint8_t BLINK_FAST = 4;

//Utilizzo comune parametri
//r=9 ==> entire row
//c=9 ==> entire col
//r=0 & c=0 ==> status led

class LedPanel {
  public:
    LedPanel();
    void init(uint8_t st_cp, uint8_t sh_cp, uint8_t ds);
    void service();
    void refresh();
    void turnOn(uint8_t row, uint8_t col);
    void turnOff(uint8_t row, uint8_t col);
    void startBlink(uint8_t row, uint8_t col, uint8_t speed);
  private:
    uint8_t _st_cp, _sh_cp, _ds;
    uint16_t _ledStatus;
    uint16_t _sentLedStatus;
    uint16_t _ledBlink[3];
    unsigned long _ledLastBlink[3];
    uint16_t _ledBlinkMs[3];
    uint8_t _ledAddress[16];
    
    uint8_t getLedAddress(uint8_t row, uint8_t col);
    void setLedStatus(uint8_t row, uint8_t col, uint8_t newStatus);


};

#endif